/* -*-c++-*- */
/* osgEarth - Geospatial SDK for OpenSceneGraph
 * Copyright 2008-2014 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#ifndef OSGEARTH_FEATURES_MVT
#define OSGEARTH_FEATURES_MVT 1

#include <osgEarth/Common>
#include <osgEarth/FeatureSource>

#ifdef OSGEARTH_HAVE_FILEGDB

namespace osgEarth
{
    /**
     * Feature Layer that accesses features via one of the many GDAL/OGR drivers.
     */
    class OSGEARTH_EXPORT FileGDBFeatureSource : public FeatureSource
    {
    public:
        class OSGEARTH_EXPORT Options : public FeatureSource::Options
        {
            META_LayerOptions(osEarth, Options, FeatureSource::Options);
            OE_OPTION(URI, url);
            OE_OPTION(std::string, table);
            Config getConfig() const;
            void fromConfig(const Config&);
        };

        META_Layer(osgEarth, FileGDBFeatureSource, Options, FeatureSource, FileGDBFeatures);

        //! Location of the File GDB resource
        void setURL(const URI& value);
        const URI& getURL() const;

        //! Which table to access in the geodatabase
        void setTable(const std::string& value);
        const std::string& getTable() const;

    public: // Layer

        virtual Status openImplementation();

        virtual Status closeImplementation();

    protected:

        virtual void init();

    public: // FeatureLayer

        virtual FeatureCursor* createFeatureCursorImplementation(const Query& query, ProgressCallback* progress);

        virtual const FeatureSchema& getSchema() const { return _schema; }

    protected:

        virtual ~FileGDBFeatureSource() { }

    private:
        FeatureSchema _schema;
        void* _db;
        void* _table;
    };
}

OSGEARTH_SPECIALIZE_CONFIG(osgEarth::FileGDBFeatureSource::Options);

#endif // OSGEARTH_HAVE_FILEGDB

#endif
